import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart';
import 'package:test/pages/welcome/state.dart';
import 'package:test/styles/common.dart';
import 'package:test/utils/screen_adapter.dart';

enum UniLinksType { string, uri }

class Entrance extends StatefulWidget {
  final WelcomeState welcomeState;

  const Entrance(this.welcomeState, {Key key}) : super(key: key);

  _EntranceState createState() => _EntranceState();
}

class _EntranceState extends State<Entrance> {
  @override
  void initState() {
    super.initState();
  }

  // @override
  // void dispose() {
  //   super.dispose();
  //   _sub.cancel();
  // }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(
        children: [
          GestureDetector(
            onTap: () async {
              Navigator.of(context)
                  .pushNamedAndRemoveUntil("home", (route) => false);
            },
            child: Container(
              color: Theme.of(context).primaryColor,
              height: MediaQuery.of(context).size.height,
            ),
          ),
          Positioned(
            right: HYSizeFit.setRpx(20),
            top: HYSizeFit.setRpx(100),
            child: GestureDetector(
              onTap: () async {
                Navigator.of(context)
                    .pushNamedAndRemoveUntil("home", (route) => false);
              },
              child: Container(
                alignment: Alignment.center,
                decoration: BoxDecoration(
                    color: Color(0x66000000),
                    borderRadius: BorderRadius.circular(HYSizeFit.setRpx(30))),
                width: HYSizeFit.setRpx(150),
                height: HYSizeFit.setRpx(60),
                child: Text(
                  "跳过",
                  style: TextStyle(color: Colors.white),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}

Widget buildView(
    WelcomeState state, Dispatch dispatch, ViewService viewService) {
  BuildContext context = viewService.context;

  /// 欢迎页面初始化
  HYSizeFit.initialize(context);
  Styles.initialize(context);

  return Entrance(state);
}
